#ifndef  __SD3078__H
#define  __SD3078__H
typedef enum 
{
	SD3078_TEMP_HIS_L = 0,   
	SD3078_TEMP_HIS_H,     
	SD3078_TEMP_AL,        
	SD3078_TEMP_AH,          
	SD3078_RD_TEMP,         
}sd3078_temp_cmd_e;
/*clk output frequency define*/
typedef enum
{
	SD3078_CLK_OUT_4096 = 0x02,  
	SD3078_CLK_OUT_1024 = 0x03,
	SD3078_CLK_OUT_64   = 0x04,
	SD3078_CLK_OUT_32   = 0x05,
	SD3078_CLK_OUT_16   = 0x06,
	SD3078_CLK_OUT_8    = 0x07,
	SD3078_CLK_OUT_4    = 0x08,
	SD3078_CLK_OUT_2    = 0x09,
	SD3078_CLK_OUT_1    = 0x0a,
	SD3078_CLK_OUT_1_2  = 0x0b,
	SD3078_CLK_OUT_1_4  = 0x0c,
	SD3078_CLK_OUT_1_8  = 0x0d,
	SD3078_CLK_OUT_1_16 = 0x0e,
	SD3078_CLK_OUT_1_SEC= 0x0f	
}sd3078_clk_out_e;

/*conut down frequency source define*/
typedef enum
{
	SD3078_COUNT_DOWN_4096  = 0x00,
	SD3078_COUNT_DOWN_1024  = 0x01,
	SD3078_COUNT_DOWN_1     = 0x02,
	SD3078_COUNT_DOWN_1_60  = 0x03
}sd3078_count_down_e;

/*alarm weekday define*/
typedef enum
{
	SD3078_SUN_ALARM = 0x01,
	SD3078_MON_ALARM = 0x02,
	SD3078_TUE_ALARM = 0x04,
	SD3078_WED_ALARM = 0x08,
	SD3078_THU_ALARM = 0x10,
	SD3078_FRI_ALARM = 0x20,
}sd3078_week_alarm_e;
/*rtc driver error code define*/
typedef enum 
{
	SD3078_EXIT_OK = 0,
	SD3078_EXIT_NO_ACK = -1,
	SD3078_EXIT_ARG_ERR = -2,
}sd3078_exit_code_e;
/*rtc flag define*/
typedef enum
{
	SD3078_OSF_FLAG = 0,
	SD3078_ALARM_TIME_FLAG,	//alarm time flag
	SD3078_COUNT_DWON_FLAG, //count down flag
	SD3078_BLF_FLAG,      
	SD3078_PMF_FLAG,
	SD3078_RTCF_FLAG
}sd3078_flag_e;

/*12 or 24 hour define*/
typedef enum
{
	SD3078_HOUR_12 = 0,
	SD3078_HOUR_24 = 1,
}sd3078_hour_type_e;

/*am or pm define,only use for*/
typedef enum
{
	SD3078_AM = 0,
	SD3078_PM,
	SD3078_AM_PM_NULL //if set 24 hour
}sd3078_am_pm_e;
/*time struct*/
typedef struct sd3078
{
	unsigned char second;
	unsigned char minute;
	unsigned char hour;
	unsigned char week;
	unsigned char day;
	unsigned char month;
	unsigned char year;
	sd3078_hour_type_e hour_type;      
	sd3078_am_pm_e am_pm;//if hour_type set as SD3078_HOUR_24, am_pm is invalid   
}sd3078_time_t;

/*charge control struct*/
typedef struct 
{
   unsigned char chage_en; /*0:disable,1:enable*/
   unsigned char resistance; /*00:10k;01:5k;10:2k;11:open*/
   
}sd3078_charge_t;

/*user ram write/read struct*/
typedef struct 
{
 unsigned char st_addr;   
 unsigned char end_addr;  
 unsigned char *buf;   
}sd3078_ram_t;

/*temperature lowest/highest alarm set*/
typedef struct 
{
 unsigned char oe;				/*temperature alarm set,0:disable,1:enable*/
 unsigned char ie;				/*temperature alarm set,0:disable,1:enable*/
 unsigned char type;				/*temperature alarm set,0:disable,1:enable*/
 signed char temp; 
}sd3078_temp_alarm_t;

/*time alarm extend struct*/
typedef struct 
{
 unsigned char sec_a;
 unsigned char min_a;
 unsigned char hour_a;
 unsigned char week_a;
 unsigned char day_a;
 unsigned char mon_a;
 unsigned char year_a;

 unsigned char ie_a;/*interrupt enable ,0:disable,1:enable*/
 unsigned char int_period;/*0:int outpute 0,1:int output pulse*/
 unsigned char enable_a;/*alarm enable;bit[6]:year,bit[5]:month,bit[4]:day,bit[3]:week,bit[2]:hour,bit[1]:minute,bit[0]:second*/
}sd3078_time_alarm_t;

/*frequency output struct*/
typedef struct 
{
 sd3078_clk_out_e freq;
 unsigned char oe;/*= clk out enable, set,0:disable,1:enable*/
}sd3078_clk_out_t;
 
/*count down struct*/
typedef struct 
{
 unsigned int count;   
 sd3078_count_down_e source;
 unsigned char ie;/*interrupt enable ,0:disable,1:enable*/
 unsigned char int_period;/*0:int outpute 0,1:int output pulse*/
}sd3078_count_down_t;

/*time api*/
sd3078_exit_code_e sd3078_get_time(sd3078_time_t *time);        	
sd3078_exit_code_e sd3078_set_time(sd3078_time_t *time);					
/*alarm api*/
sd3078_exit_code_e sd3078_read_alarm_time(sd3078_time_alarm_t *alarm);			
sd3078_exit_code_e sd3078_set_alarm_time(sd3078_time_alarm_t *alarm);			
 
sd3078_exit_code_e sd3078_set_alarm_temp(sd3078_temp_alarm_t *temp,  sd3078_temp_cmd_e cmd); 
sd3078_exit_code_e sd3078_get_Alarm_temp(signed char *Temp,sd3078_temp_cmd_e cmd);  

sd3078_exit_code_e sd3078_get_temperature(signed char *temp);			
sd3078_exit_code_e sd3078_get_his_temperature(signed char *temp, sd3078_temp_cmd_e cmd);     	
sd3078_exit_code_e sd3078_get_his_temp_time(sd3078_time_t *time, sd3078_temp_cmd_e cmd);			
sd3078_exit_code_e sd3078_battery_i2c_ctrl(unsigned char en);						
 
/*battery manage*/
sd3078_exit_code_e sd3078_read_battery_voltage(unsigned short *vol);		
sd3078_exit_code_e sd3078_battery_charge_ctrl(sd3078_charge_t *ctrl);		

/*user ram*/
sd3078_exit_code_e sd3078_read_ram(sd3078_ram_t *ram);					
sd3078_exit_code_e sd3078_write_ram(sd3078_ram_t *ram);				

/*device id*/
sd3078_exit_code_e sd3078_read_device_id(unsigned char *buf);		
 /*clk out*/   
sd3078_exit_code_e sd3078_clk_out(sd3078_clk_out_t *clk);				
/*count down*/ 
sd3078_exit_code_e sd3078_count_down(sd3078_count_down_t *count_down);		
/*flag set and clear*/
sd3078_exit_code_e sd3078_flag_clear(sd3078_flag_e flag);											
sd3078_exit_code_e sd3078_flag_get(sd3078_flag_e flag, unsigned char *value);			
#endif
